package com.yakaten.action;

import java.io.IOException;

import org.seasar.framework.util.ResourceUtil;
import org.seasar.struts.annotation.Execute;

public class LoginAction extends BaseAction {

	public String userName;

	public String password;

    @Execute(validator = false)
	public String index() {
        return "../login.jsp";
	}

    @Execute(validator = false)
	public String login() throws IOException {
    	String lUserName = ResourceUtil.getProperties("yakaten.properties")
    	.getProperty("system.userName");

    	String lPassword = ResourceUtil.getProperties("yakaten.properties")
    	.getProperty("system.password");
    	if(userName.equals(lUserName)&&password.equals(lPassword)){
    		request.getSession().setAttribute("loginFlg", "true");
    		response.getWriter().write("success");
    	}
    	return null;
	}

    @Execute(validator = false)
	public String logout() throws IOException {
    	request.getSession().removeAttribute("loginFlg");
    	response.getWriter().write("success");
    	return null;
	}
}
